<template>
  <su-popup :show="show" type="center" @close="$emit('close')">
    <view class="node-detail-popup">
      <view class="popup-header">
        <view class="avatar-section">
          <image v-if="nodeInfo?.avatarUrl" :src="nodeInfo.avatarUrl" class="detail-avatar" />
          <view v-else class="detail-avatar-placeholder">
            {{ nodeInfo?.name?.charAt(0)?.toUpperCase() || '?' }}
          </view>
        </view>
        <view class="name-section">
          <text class="detail-name">{{ nodeInfo?.name || nodeInfo?.text || '未知' }}</text>
        </view>
        <button class="close-btn" @tap="$emit('close')">×</button>
      </view>
      <view class="popup-content">
        <view v-if="nodeInfo?.nickname" class="detail-item">
          <text class="detail-label">昵称：</text>
          <text class="detail-value">{{ nodeInfo.nickname }}</text>
        </view>
        <view v-if="nodeInfo?.phone" class="detail-item">
          <text class="detail-label">手机号：</text>
          <text class="detail-value">{{ nodeInfo.phone }}</text>
        </view>
        <view v-if="nodeInfo?.company" class="detail-item">
          <text class="detail-label">企业：</text>
          <text class="detail-value">{{ nodeInfo.company }}</text>
        </view>
        <view v-if="nodeInfo?.position" class="detail-item">
          <text class="detail-label">职位：</text>
          <text class="detail-value">{{ nodeInfo.position }}</text>
        </view>
        <view v-if="nodeInfo?.homeAddress" class="detail-item">
          <text class="detail-label">家庭住址：</text>
          <text class="detail-value">{{ nodeInfo.homeAddress }}</text>
        </view>
      </view>
    </view>
  </su-popup>
</template>

<script>
import SuPopup from '@/sheep/ui/su-popup/su-popup.vue';

export default {
  name: 'NodeDetailPopup',
  components: {
    SuPopup
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    nodeInfo: {
      type: Object,
      default: () => null
    }
  },
  emits: ['close'],
  methods: {
    // 移除了formatDate方法，因为不再显示时间字段
  }
}
</script>

<style scoped>
/* 节点详细信息弹窗样式 */
.node-detail-popup {
  width: 320px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.popup-header {
  display: flex;
  align-items: center;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  position: relative;
}

.avatar-section {
  margin-right: 12px;
}

.detail-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.detail-avatar-placeholder {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.name-section {
  flex: 1;
}

.detail-name {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 2px;
  display: block;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.popup-content {
  padding: 16px;
}

.detail-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 12px;
  padding: 8px;
  background: #f8fafc;
  border-radius: 6px;
  border-left: 3px solid #667eea;
}

.detail-item:last-child {
  margin-bottom: 0;
}

.detail-label {
  font-size: 14px;
  color: #374151;
  font-weight: 500;
  min-width: 50px;
  margin-right: 8px;
}

.detail-value {
  font-size: 14px;
  color: #111827;
  flex: 1;
  line-height: 1.4;
}
</style> 